package com.zy.chapter5

/**
 * @description: ${description}
 * @author: zhaoyi
 * @create: 2020-04-23 23:21
 **/
class Counter {

  //只能this对象访问，一般用不到
  private[this] val age = 1

  private val name = "zs"

  def compare(other: Counter) = {

    //private[this] 严格的现在不能访问其他Counter对象age字段
    //this.age.compareTo(other.age)

    //scala认为都是Counter对象，即使private也可以访问
    this.name.compareTo(other.name)
  }

}
